import time
import datetime
print(time.localtime(1434502529))
print(type(time.localtime()))
print(datetime.datetime.now().weekday())

a = datetime.datetime.now()
print(type(a))
str1 = "2022-2-22"
day_obj = datetime.datetime.strptime(str1,'%Y-%m-%d')
print(day_obj.weekday())
print(day_obj.hour)

import re
# import os
# app = r'/Users/show/tools/wget-1.21.4-winarm64/wget.exe'
# taget_path = '/Users/show/Downloads'
# taget_url = 'http://www.listeningexpress.com/studioclassroom/ad/'


# # os.system(f'{app} -O index.html {taget_url}')
# # print('执行完毕')

# import requests

# res = requests.get(taget_url)
# print(res.text)
# target_str = res.text
# regex_p = r"javascript:p\('(.*?)\.mp3'\)"
# r = re.compile(regex_p)
# lists = r.findall(target_str)
# for i in lists:
#     print(i)

import yaml
import random
import string
def generate_token(length=16):
    """生成指定长度的随机字符串（字母 + 数字）"""
    characters = string.ascii_letters + string.digits  # a-z, A-Z, 0-9
    return ''.join(random.choices(characters, k=length))

path = '/Users/show/PythonAndQA(code)/python-study2025/8_anything/5example.yaml'
with open(path,'r',encoding='utf-8') as f:
    yaml_obj = yaml.safe_load(f)

    t = yaml_obj[2]
    print(t)
print('-------')
login_token = generate_token()
t_str = yaml.safe_dump(t)
reg_exp = r'\${(.*?)}'

def subs_fuc(match):
    tar = match[1]
    tar_all = match[0]
    print(tar_all)
    return eval(tar)

z = re.sub(reg_exp,subs_fuc,t_str)
print(z)

case_list = [{'cai':1}]
case_list2 = [{'yan':3},{'pei':2}]
# cc = dict(*case_list)
# print(cc)
def mo(di1):
    print(type(di1))
    print(di1)

def pin(di1,di2):
    if isinstance(di1,dict) and isinstance(di2,dict):
        di1.update(di2)
        print(di1)
    else:
        print(f'类型是{type(di1)}')

mo(*case_list)
mo(case_list)


pin(*case_list2)

dic1 = {
    'cai':1,
    'pei':2,
    'yan':3
}
zz = yaml.dump(dic1)
print(zz)
print(type(zz))

import requests

str1 = '我是caipeiyan'
res = requests.post('http://127.0.0.1:8082/post',
                    params={'key':'111'},
                    data=str1.encode('utf-8'),
                    headers={'athor':'ccc'})
print(res.json())